from django.shortcuts import render
from django import forms
from django.forms import ModelForm
from django.forms import widgets as wdt
from app01 import models
# Create your views here.
class BootstrapForm(ModelForm):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for name, field in self.fields.items():
            field.widget.attrs['class'] = 'form-control'
            field.widget.attrs['placeholder'] = '请输入%s' % (field.label,)

def register(request):
    uform = RegisterForm()
    return render(request,'app01/register.html',{'form':uform})

class RegisterForm(BootstrapForm):
    confirm_password = forms.CharField(
        label='重复密码',
        widget=forms.PasswordInput(attrs={"custom":"tttt","style":"width:150px;height:60px;"}))
    code = forms.CharField(
        label='验证码',
        widget=forms.TextInput())
    class Meta:
        model = models.UserInfoTest
        fields = "__all__"
        exclude = ['user_id']

        widgets = {
            "email":wdt.TextInput(attrs={"style":"height:55px;"})
        }

